package com.changcheng.project.yuminsi.controller;


import com.changcheng.framework.aspectj.LogPointcut;
import com.changcheng.project.yuminsi.service.TempService;
import com.changcheng.project.yuminsi.vo.BaseOutput;
import com.changcheng.project.yuminsi.vo.CcCodeResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yuminsi
 * @description
 * @date 2020/9/16 14:38
 * @since
 */
@Api(description = "备用接口")
@RestController
public class TempController {

    @Autowired
    private TempService tempService;

    /**
     * 国密IC卡消费计算MAC:密钥体系（0聚利，1速通）+4字节区域代码+8字节卡内部编号+4字节伪随机数+2字节脱机交易序号
     * +1字节密钥版本号+1字节算法标识+4字节消费金额+6字节终端机编号+4字节终端交易序号+7字节交易时间+返回IC卡COS指令
     *
     * @param strAreaCodeNumber
     * @param strIcSerialNumber
     * @param strRand
     * @param strIccTradeSerialNum
     * @param strKeyVer
     * @param strAlgId
     * @param strConsumeNumber
     * @param strTerminalNum
     * @param strPsamTradeNum
     * @param strDateTime
     */
    @ApiOperation(value = "IC卡复合消费消费计算Mac", notes = "IC卡复合消费消费计算Mac")
    @LogPointcut(description = "IC卡复合消费消费计算Mac")
    @PostMapping("/etc/card/consume")
    public BaseOutput consumeCalMac(@RequestParam("strAreaCodeNumber") String strAreaCodeNumber,
                                    @RequestParam("strIcSerialNumber") String strIcSerialNumber,
                                    @RequestParam("strRand") String strRand,
                                    @RequestParam("strIccTradeSerialNum") String strIccTradeSerialNum,
                                    @RequestParam("strKeyVer") String strKeyVer,
                                    @RequestParam("strAlgId") String strAlgId,
                                    @RequestParam("strConsumeNumber") String strConsumeNumber,
                                    @RequestParam("strTerminalNum") String strTerminalNum,
                                    @RequestParam("strPsamTradeNum") String strPsamTradeNum,
                                    @RequestParam("strDateTime") String strDateTime) {
        return tempService.consumeCalMac(strAreaCodeNumber, strIcSerialNumber, strRand, strIccTradeSerialNum,
                strKeyVer, strAlgId, strConsumeNumber, strTerminalNum, strPsamTradeNum, strDateTime);
    }


    /**
     * 国密ESAM解密车辆密文:密钥体系（0聚利，1速通）+4字节区域代码+8字节OBU合同序列号+8字节随机数+N字节车辆信息密文
     * +1字节加密密钥版本+返回车辆信息明文
     *
     * @param strAreaCodeNumber
     * @param strEsamSerialNumber
     * @param strRand
     * @param strEnCryptData
     * @param strKeyVer
     */
    @ApiOperation(value = "解密车辆信息", notes = "解密车辆信息")
    @LogPointcut(description = "解密车辆信息")
    @PostMapping("/etc/obu/decryptvehi")
    public BaseOutput decryptVehi(@RequestParam("strAreaCodeNumber") String strAreaCodeNumber,
                                  @RequestParam("strEsamSerialNumber") String strEsamSerialNumber,
                                  @RequestParam("strRand") String strRand,
                                  @RequestParam("strEnCryptData") String strEnCryptData,
                                  @RequestParam("strKeyVer") String strKeyVer) {
        return tempService.decryptVehi(strAreaCodeNumber, strEsamSerialNumber, strRand, strEnCryptData, strKeyVer);
    }

}
